package com.cictec.middleware.gps.service.feign;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cictec.middleware.commons.utils.DateUtils;
import com.cictec.middleware.commons.utils.PMSUtils;
import com.cictec.middleware.commons.utils.Result;
import com.cictec.middleware.core.entity.Bus;
import com.cictec.middleware.core.entity.BusCharter;
import com.cictec.middleware.core.entity.BusDriverSignIn;
import com.cictec.middleware.core.entity.BusLine;
import com.cictec.middleware.core.entity.BusLineMapPoint;
import com.cictec.middleware.core.entity.BusLineStation;
import com.cictec.middleware.core.entity.BusParkReturnNote;
import com.cictec.middleware.core.entity.BusScheduleApply;
import com.cictec.middleware.core.entity.BusTimingPointSupply;
import com.cictec.middleware.core.entity.DeparterSchedule;
import com.cictec.middleware.core.entity.StandbyZone;
import com.cictec.middleware.core.entity.WarnMsg;
import com.cictec.middleware.feign.dc.MiddlewareDcBusScheduleServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcBusServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcBusWarnServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcDeviceServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcDriverServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcLineServiceFeign;
import com.cictec.middleware.feign.dc.MiddlewareDcTimingPointServiceFeign;
import com.cictec.middleware.gps.engine.caculate.entity.BusMileage;
import com.cictec.middleware.gps.engine.caculate.entity.BusTrip;
import com.cictec.middleware.gps.service.BusDriverService;

@Service
public class MiddlewareDcFeignClient {

	private static Logger logger = LoggerFactory.getLogger(BusDriverService.class);
	
	@Autowired
	private MiddlewareDcLineServiceFeign middlewareDcLineServiceFeign;
	@Autowired
	private MiddlewareDcDriverServiceFeign middlewareDcDriverServiceFeign;
	@Autowired
	private MiddlewareDcDeviceServiceFeign middlewareDcDeviceServiceFeign;
	@Autowired
	private MiddlewareDcBusServiceFeign middlewareDcBusServiceFeign;
	@Autowired
	private MiddlewareDcBusScheduleServiceFeign middlewareDcBusScheduleServiceFeign;
	@Autowired
	private MiddlewareDcBusWarnServiceFeign middlewareDcBusWarnServiceFeign;
	@Autowired
	private MiddlewareDcTimingPointServiceFeign middlewareDcTimingPointServiceFeign;
	

	public List<BusLine> getListBusLine() {
		
		List<BusLine> list = middlewareDcLineServiceFeign.getListBusLine();
		return list;
	}

	public BusLine getBusLine(String lineUuid) {
		BusLine line = middlewareDcLineServiceFeign.getBusLine(lineUuid);
		return line;
	}

	public Map<String, List<BusLineMapPoint>> getBusLineMapPoint(String lineUuid) {
		Map<String, List<BusLineMapPoint>> map = middlewareDcLineServiceFeign.getBusLineMapPoint(lineUuid);
		
		return map;
	}

	public Map<String, List<BusLineStation>> getBusLineStation(String lineUuid) {
		Map<String, List<BusLineStation>> map = middlewareDcLineServiceFeign.getBusLineStation(lineUuid);
		return map;
	}

	public List<StandbyZone> getBusLineStandby(String lineUuid) {
		List<StandbyZone> list = middlewareDcLineServiceFeign.getBusLineStandby(lineUuid);
		return list;
	}


	public List<BusDriverSignIn> selectSignByBusUuid(String busUuid, String date) {
		logger.error("查询dc司机签到信息");
		
		return middlewareDcDriverServiceFeign.getBusDriverSignIn(busUuid, date);
	}
	
	public List<DeparterSchedule> selectBusRunScheduleDayList(Map params){
		return middlewareDcBusScheduleServiceFeign.selectBusRunScheduleDayList(params);
	}

	public void updateBusLoginDriver(String busUuid, String drvUuid, Date loginTime) {
		// TODO Auto-generated method stub

	}

	public void updateForceNonoperStatus(Bus bus) {
		middlewareDcBusServiceFeign.updateForceNonoperStatus(bus);

	}

	public void updateBusWorkingLine(Bus bus) {
		middlewareDcBusServiceFeign.updateBusWorkingLine(bus);
	}

	public void updateDeviceOnlineStatusByDevUuid(String devUuid, String devOnlineStatus) {
		middlewareDcDeviceServiceFeign.updateDeviceOnlineStatusByDevUuid(devUuid, devOnlineStatus);
	}


	public void saveWarn(WarnMsg warnMsg) {
		Result result = middlewareDcBusWarnServiceFeign.saveWarn(warnMsg);
		String warnUuid = (String) result.getData();
		if(PMSUtils.isEmpty(warnMsg.getWarnUuid()) && warnUuid != null){
			warnMsg.setWarnUuid(warnUuid);
		}
	}

	public void deleteWarn(String date, String warnType, String busUuid) {
		middlewareDcBusWarnServiceFeign.deleteWarn(date, warnType, busUuid);

	}

	public List<BusTimingPointSupply> selectListBusTimingPointSupply(String date, boolean isSupply) {
		// TODO Auto-generated method stub
		return middlewareDcTimingPointServiceFeign.getBusPosition(date, isSupply);
	}

	public void saveTimingPointSupply(String devCode, String date, String supFlag, String supRepairFlag) {
		// TODO Auto-generated method stub

	}

	public void saveBusParkReturnNote(BusParkReturnNote note) {
		// TODO Auto-generated method stub

	}

	public void saveBusScheduleApply(BusScheduleApply busScheduleApply) {
		// TODO Auto-generated method stub

	}

	public List<BusScheduleApply> selectBusScheduleApply(String busUuid, Date time) {
		// TODO Auto-generated method stub
		return middlewareDcBusServiceFeign.getBusScheduleApply(busUuid, time);
	}

	public void updateScheduleDriver(Date signTime, String lineUuid, String busUuid, String drvUuid) {
		// TODO Auto-generated method stub

	}

	public void updateScheduleDepartureFlag(String date, String busUuid) {
		// TODO Auto-generated method stub
		middlewareDcBusScheduleServiceFeign.updateScheduleDepartureFlag(date, busUuid);
	}

	public void updateScheduleTripStartOrEndTime(String brsdUuid, Date startTime, Date endTime) {
		// TODO Auto-generated method stub

	}

	public void updateBusSchedule(String lineUuid, String lineType, String busUuid, String drvUuid, Date actStartTime,
			Date actArraveTime) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("lineUuid", lineUuid);
		params.put("lineType", lineType);
		params.put("busUuid", busUuid);
		params.put("drvUuid", drvUuid);
		params.put("actStartTime", DateUtils.formatDateTime(actStartTime));
		params.put("actArraveTime", DateUtils.formatDateTime(actArraveTime));
		middlewareDcBusScheduleServiceFeign.updateBusSchedule(params);
		System.out.println("ok");

	}

	public void saveTrip(String busUuid, BusTrip busTrip, List<BusMileage> mileageList) {
		// TODO Auto-generated method stub

	}

	public List<BusCharter> getBusCharter(String busUuid, Date date) {
		// TODO Auto-generated method stub
		return middlewareDcBusServiceFeign.getBusCharter(busUuid, date);
	}

}
